<div class="container-fluid">
    产品编号:<input type="text" id="productCode">
    产品名称:<input type="text" id="productName"/>
    库存数量范围:<input type="text" id="min" placeholder="最小值" value="0">
    <input type="text" id="max" placeholder="最大值">
    <button class="btn btn-primary" type="button" onclick="Query()">查询</button>
</div>
<table class="table" id="somainDiv">
    <thead>
    <tr>
        <th>序号</th>
        <th>产品编号</th>
        <th>产品名称</th>
        <th>库存数量</th>
        <th>采购在途数</th>
        <th>销售在途数</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>

<script id="productQueryTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{index+1}}</td>
        <td>{{value.productCode}}</td>
        <td>{{value.name}}</td>
        <td>{{value.num}}</td>
        <td>{{value.poNum}}</td>
        <td>{{value.soNum}}</td>
        <td><input type="button" value="查看变更记录" onclick="record('{{value.productCode}}')"></td>
    </tr>
    {{/each}}
</script>
<script>
    $(function () {
        showPage({
            currentPage: 1,
            pageSize: 2,
            url: '/getAllProductForStore',
            templateId: 'productQueryTemplate',
            contentId: 'tableBody',
            params: {
                id: 1
            }
        })
    })
    function record(obj) {
        window.sessionStorage.setItem("storeProductCode",obj)
        show("/store/inStockRecord.html")
    }
    function Query() {
        Ajax.post(
            "/selectProductForStockRecord",
            {
                productCode:$("#productCode").val(),
                name:$("#productName").val(),
                min:$("#min").val(),
                max:$("#max").val()
            },
            function (result) {
                var div=document.getElementById("tableBody")
                var html=template('productQueryTemplate',{data:result.data})
                div.innerHTML=html
            }
        )
    }
</script>